5.2 System Startup
Upon receiving system control, the U-BOOT bootloader first initializes the exception vector table. For ARM systems, the source code for this low-level component is written in ARM assembly language and is maintained within the file git/arch/arm/lib/vectors.S. This file defines the following exception vector matrix. Once compiled into binary machine code, the linker mechanism places this exception vector table directly into the .vectors section starting at the global symbol _start. The linker script explicitly places this section at the absolute base entry point of the compiled U-BOOT binary image.
.macro ARM_VECTORS
b reset
ldr pc, _undefined_instruction
ldr pc, _software_interrupt
ldr pc, _prefetch_abort
ldr pc, _data_abort
ldr pc, _not_used
ldr pc, _irq
ldr pc, _fiq
.endm
.globl _start
.section ".vectors", "ax"
_start:
ARM_VECTORS
As shown in this assembly fragment, the absolute first instruction of the U-BOOT binary is an unconditional branch command jumping to the reset handler. The remaining exception vector slots utilize ldr instructions to load the starting memory addresses of their respective exception handlers directly into the Program Counter (pc) register, managing the corresponding hardware trap events. These underlying handlers and their target memory labels are fully declared within vectors.S. Because these routines are straightforward, they are omitted here for brevity; interested readers can review the source code in vectors.S.
It must be explicitly noted that if the platform is configured to leverage an SPL-based boot flow, this exception vector table definition is left empty, containing only a single unconditional jump instruction. Under this configuration, the final configuration of the active exception vector table is deferred and handled downstream by the running SPL routine.
The reset label is exposed globally within start.S, causing execution to branch directly into the code maintained inside start.S. For the i.MX6 Solo/DualLite processors, the start.S source file resides within the directory path git/arch/arm/cpu/armv7/.
The initial execution sequence in start.S forces the CPU core into Supervisor (SVC32) mode, masks out the IRQ and FIQ line interrupts, and modifies specific CP15 coprocessor control registers to configure internal caches, provision the memory management sub-blocks, and configure basic memory page translation tables. The following diagram charts the core assembly-level CPU initialization flow executed inside the start.S routine:
Figure 5-4 Initialization Flowchart
.globl reset
.globl save_boot_params_ret
.type save_boot_params_ret,%function
reset:
b save_boot_params
save_boot_params_ret:
mrs r0, cpsr
and r1, r0, #0x1f @ mask mode bits
teq r1, #0x1a @ test for HYP mode
bicne r0, r0, #0x1f @ clear all mode bits
orrne r0, r0, #0x13 @ set SVC mode
orr r0, r0, #0xc0 @ disable FIQ and IRQ
msr cpsr,r0
bl cpu_init_cp15
bl cpu_init_crit
bl _main
ENTRY(save_boot_params)
b save_boot_params_ret @ back to my caller
ENDPROC(save_boot_params)
.weak save_boot_params
At the reset execution entry block, the code invokes an unconditional branch jumping into the save_boot_params subroutine to protect the boot registers handed down by the precursor ROM stage. In the default fallback path, this subroutine consists of a basic branch command that immediately returns back to the save_boot_params_ret marker, where the core proceeds to disable incoming asynchronous interrupts. Declaring the symbol as .weak save_boot_params allows system architects to override this routine. Developers can implement a custom save_boot_params implementation within board_init.c or alternative platform files to fully suppress or replace the baseline tracking code defined here. To strictly optimize the binary footprint, start.S relies extensively on preprocessor conditional compilation macros rather than runtime logical statements to initialize various system configurations.
If the platform build files do not define the configuration overrides CONFIG_SKIP_LOWLEVEL_INIT or CONFIG_SKIP_LOWLEVEL_INIT_ONLY, the system advances to call the lowlevel_init assembly routine. This code block resides within git/arch/arm/cpu/armv7/lowlevel_init.S and is responsible for carving out a temporary stack frame inside internal volatile storage. The target address parameters for this temporary stack differ significantly depending on whether the system is compiled under an SPL configuration or an ordinary non-SPL Proper build. The lowlevel_init routine subsequently invokes the s_init helper subroutine located within the same file. Upon completion, s_init returns control back to the original function block that initiated the call to lowlevel_init. This routine is exported with a weak linker attribute, permitting developers to easily substitute their own custom hardware initialization hooks.